import { IPSDEDRBar } from './ipsdedrbar';
import { IPSDEDRBarGroup } from './ipsdedrbar-group';
import { PSDEDRCtrlImpl } from './psdedrctrl-impl';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEDRBarImpl extends PSDEDRCtrlImpl implements IPSDEDRBar {
  protected psdedrbargroups: IPSDEDRBarGroup[] | null = null;

  getPSDEDRBarGroups(): IPSDEDRBarGroup[] | null {
    if (this.psdedrbargroups == null) {
      this.psdedrbargroups = this.fillChildListModel(this.M.getPSDEDRBarGroups, 'control.drctrl.IPSDEDRBarGroup') as IPSDEDRBarGroup[];
    }
    return this.psdedrbargroups;
  }

  get psDEDRBarGroups(): IPSDEDRBarGroup[] | null {
    return this.getPSDEDRBarGroups();
  }

  findPSDEDRBarGroup(objKey: any): IPSDEDRBarGroup | null {
    return this.getPSModel5('control.drctrl.IPSDEDRBarGroup', this.getPSDEDRBarGroups(), objKey) as IPSDEDRBarGroup;
  }

  get title(): string {
    return this.M.title;
  }

  protected titlepslanguageres: IPSLanguageRes | null = null;

  getTitlePSLanguageRes(): IPSLanguageRes | null {
    if (this.titlepslanguageres != null) return this.titlepslanguageres;
    const value = this.M.getTitlePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.titlepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getTitlePSLanguageRes') as IPSLanguageRes;
    return this.titlepslanguageres;
  }

  get titlePSLanguageRes(): IPSLanguageRes | null {
    return this.getTitlePSLanguageRes();
  }

  getTitlePSLanguageResMust(): IPSLanguageRes {
    const value = this.getTitlePSLanguageRes();
    if (value == null) {
      throw new Error('未指定抬头语言资源');
    }
    return value;
  }

  get showTitle(): boolean {
    return this.M.showTitle;
  }

  get cls(): string {
    return 'PSDEDRBarImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSControlContainer' || cls == 'control.drctrl.IPSDEDRBar' || cls == 'control.drctrl.IPSDRBar') return true;
    return super.instanceof(cls);
  }
}
